//
//  ICChatMessageRedPacketCell.m
//  ICome
//
//  Created by 席鹏飞 on 2016/11/25.
//  Copyright © 2016年 iCom. All rights reserved.
//

#import "ICChatMessageRedPacketCell.h"
#import "ICRedPacketButton.h"
#import "ICMessageModel.h"
#import "ICHeaderFile.h"
@interface ICChatMessageRedPacketCell ()

@property (nonatomic, strong) ICRedPacketButton *redPacketButton;

@end

@implementation ICChatMessageRedPacketCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self.contentView addSubview:self.redPacketButton];
    }
    return self;
}

- (void)setModelFrame:(ICMessageFrame *)modelFrame
{
    [super setModelFrame:modelFrame];
    
    self.redPacketButton.frame = modelFrame.picViewF;
    self.redPacketButton.messageModel = modelFrame.model;
}

#pragma mark - Event

- (void)redPacketBtnClicked
{
    [self routerEventWithName:GXRouterEventRedPacketTapEvent
                     userInfo:@{MessageKey : self.modelFrame,
                                }];
}

#pragma mark - Getter

- (ICRedPacketButton *)redPacketButton
{
    if (!_redPacketButton) {
        _redPacketButton = [ICRedPacketButton buttonWithType:UIButtonTypeCustom];
        [_redPacketButton addTarget:self action:@selector(redPacketBtnClicked) forControlEvents:UIControlEventTouchUpInside];
    }
    return _redPacketButton;
}

@end
